package com.map;

import java.util.concurrent.ConcurrentHashMap;

/**
 * @author: csh
 * @Date: 2023/1/11 21:52
 * @Description:
 */
public class ConcurrentHashMapStudy {
    public static void main(String[] args) {
        ConcurrentHashMap map = new ConcurrentHashMap(32);
        map.put("a",1);
        map.put("b",2);
        map.put("c",3);
        System.out.println(map.toString());
        //添加不成功，返回旧值，原因是原来的key已存在
        Object a = map.putIfAbsent("a", 2);
        System.out.println(a);
        //添加成功 返回Null
        Object d = map.putIfAbsent("d", 5);
        System.out.println(d);
        System.out.println(map.toString());


    }
}
